# -*- coding: UTF-8 -*-

import time,os
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.chrome.options import Options

chrome=Options()
chrome.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
chrome_driver = r"D:\Programs\Python\Python37\chromedriver.exe"   ##驱动对应地址
path = os.path.join("file:///", os.getcwd(), "selenium.html")

def aler():
    driver=webdriver.Chrome(chrome_driver,chrome_options=chrome)
    driver.get(path)
    driver.maximize_window()
    time.sleep(3)
    driver.find_element_by_css_selector("div#signup  input[name='username']").send_keys("rabbit")
    driver.find_element_by_css_selector("div#signup  input[name='password']").send_keys("rabbit")
    rn=driver.find_element_by_css_selector("div#signup  input[name='remeber']")
    rn.click()
    rmn=driver.find_element_by_css_selector("div#signup  input[name='multi_login']")
    rmn.click()
    lgn=driver.find_element_by_css_selector("div#signup  input[type='submit']")
    lgn.click()
    WebDriverWait(driver,5).until(EC.alert_is_present())
    alern=driver.switch_to.alert
    print(alern.text)
    alern.accept()
    time.sleep(2)
    driver.quit()

aler()